<%@ page import="com.party.core.model.system.TargetType" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<%@ taglib prefix="memberForm" uri="http://www.tongxingzhe.cn/memberForm" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>${empty activity.id ? '发布' : '编辑'}众筹项目</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/ui/activity/publish_act.css">
    <link rel="stylesheet" href="${ctx}/static/uploadCI/upload.css">
    <link rel="stylesheet" href="${ctx}/css/common/img_text.css">
    <style type="text/css">
        #eventDataDivNew .limit-num-label {
            padding: 0;
            height: 30px;
            line-height: 30px;
            width: 130px !important;
        }

        .img-item1 {
            position: relative;
            width: 155px !important;
            height: 220px !important;
            border: 5px solid #e6e6e6;
            margin-bottom: 0px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: cover;
            cursor: pointer;
            float: none;
        }

        .activity-label {
            vertical-align: top;
        }

        .activity-info-new {
            width: calc(100% - 110px);
        }

        .multiple-activity-fb .m-height {
            height: auto !important;
        }
    </style>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <div id="hidden_show_plane" class="pt15" style="display: none;">
        <div class="dib l" style="width: 50%;">
            <div class="pt10 pb10" style="border-right: 1px solid #7f7f7f;">
                <div class="show-img"
                     style="background-image: url(../../image/activity/hidden_show_before.jpg);"></div>
            </div>
            <p class="mt10 f18 tc">（未隐藏数据前）</p>
        </div>
        <div class="dib l" style="width: 50%;">
            <div class="pt10 pb10">
                <div class="show-img"
                     style="background-image: url(../../image/activity/hidden_show_after.jpg);"></div>
            </div>
            <p class="mt10 f18 tc">（隐藏数据后）</p>
        </div>
    </div>
    <div id="hidden_show_plane3" class="pt15" style="display: none;">
        <div class="dib l" style="width: 50%;">
            <div class="pt10 pb10" style="border-right: 1px solid #7f7f7f;">
                <div class="show-img"
                     style="background-image: url(../../image/activity/display_after.png);background-size: contain"></div>
            </div>
            <p class="mt10 f18 tc">（不显示同行戈友）</p>
        </div>
        <div class="dib l" style="width: 50%;">
            <div class="pt10 pb10">
                <div class="show-img"
                     style="background-image: url(../../image/activity/display_before.png);background-size: contain"></div>
            </div>
            <p class="mt10 f18 tc">（显示同行戈友）</p>
        </div>
    </div>
    <div id="hidden_show_plane2" class="pt15" style="display: none;">
        <div class="show-img"
             style="background-image: url(../../image/activity/edit_share.jpg); width: 100%!important; height: 895px!important;"></div>
    </div>
    <!--内容-->
    <section>
        <div class="section-main">
            <!-- 正文请写在这里 -->
            <div class="add-form-content">
                <form id="myForm" class="layui-form mt20" method="post" action="${ctx}/activity/zcActivity/save.do">
                    <div class="preview-box">
                        <div class="top-tip">
                            <span class="tip-inner"><span class="tip-title">效果预览</span></span>
                        </div>
                        <a class="preview-btn layui-btn layui-btn-danger layui-btn-sm" href="javascript:void(0)"
                           lay-submit
                           lay-filter="*"><i class="iconfont icon-refresh btn-icon"></i>预览</a>
                        <iframe style="width: 360px;height: 760px;"
                                src="${ctx}/phone/preview/zc.do?url=/micWeb/html/project/target_preview.html?id=${activity.id}&type=${crowdfundEvent.isMultiple == 1 ? 'multi' : ''}"
                                frameborder="0"></iframe>
                    </div>
                    <div class="form-outer">
                        <input type="hidden" lay-verify="groupIsExpire"/>
                        <input type="hidden" name="isCrowdfunded" value="1"/>
                        <div class="event-content">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">选择主题<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline" id="eventIdDiv">
                                        <c:if test="${crowdfundEvent != null}">
                                            <input type="text" value="${crowdfundEvent.name}" class="layui-input"
                                                   disabled/>
                                        </c:if>
                                        <c:if test="${crowdfundEvent == null}">
                                            <select id="eventId" lay-verify="eventId"
                                                    lay-filter="eventId" ${not empty activity.eventId ? 'disabled' : ''}>
                                                <option value="">无主题</option>
                                                <c:forEach var="event" items="${crowdfundEventList}">
                                                    <option value="${event.id}" ${activity.eventId == event.id ? 'selected="selected"' : ""}>${event.name}</option>
                                                </c:forEach>
                                            </select>
                                        </c:if>
                                        <input type="hidden" name="eventId" value="${activity.eventId}"/>
                                    </div>
                                </div>
                            </div>
                            <div id="eventDataDiv" ${not empty activity.eventId && crowdfundEvent.isMultiple == 0 ? '' : 'style="display:none"'}>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">报名截止时间：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input end-time" lay-verify="endDate"
                                                   value="<fmt:formatDate value="${activity.endTime}" pattern="yyyy-MM-dd HH:mm"/>"
                                                   disabled>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">活动开始时间：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" class="layui-input start-time" lay-verify="startDate"
                                                   value="<fmt:formatDate value="${activity.startTime}" pattern="yyyy-MM-dd HH:mm"/>"
                                                   disabled>
                                        </div>
                                    </div>
                                </div>
                                <%--<div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">人数上限：</label>
                                        <div class="layui-input-inline">
                                            <span class="limit-num"
                                                  style="height: 30px;line-height: 30px;padding-left: 10px;">${activity.limitNum}</span>人
                                            <input type="hidden" class="layui-input limit-num"
                                                   value="${activity.limitNum}"
                                                   disabled lay-verify="limitNum">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">活动金额：</label>
                                        <div class="layui-input-inline">
                                            <span class="price"
                                                  style="height: 30px;line-height: 30px;padding-left: 10px;"><fmt:formatNumber
                                                    value="${activity.price}" pattern="0.00"/></span>元/位
                                            <input type="hidden" class="layui-input price" lay-verify="price"
                                                   value="<fmt:formatNumber value="${activity.price}" pattern="0.00"/>">
                                        </div>
                                    </div>
                                </div>--%>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">活动地点：</label>
                                        <div class="layui-input-inline" style="width: 500px">
                                            <input type="text" class="layui-input address" value="${address}" disabled
                                                   lay-address="price">
                                        </div>
                                    </div>
                                </div>
                                <c:set var="numArray" value="${fn:split('一,二,三', ',')}"></c:set>
                                <c:forEach var="counterfoil" items="${counterfoils}" varStatus="status">
                                    <div class="layui-form-item multiple-activity-fb count-activity-fb">
                                        <label class="activity-num">套餐${numArray[status.index]}</label>
                                        <div class="activity-place">
                                            <div class="m-height">
                                                <label class="activity-label">名称：</label>
                                                <div class="activity-info">${counterfoil.name}</div>
                                            </div>
                                            <div class="m-height">
                                                <label class="activity-label">金额：</label>
                                                <div class="activity-info">
                                                    <fmt:formatNumber value="${counterfoil.payment}" pattern="#.##"/>元
                                                </div>
                                                <label class="activity-label">限制数量：</label>
                                                <div class="activity-info">
                                                    <fmt:formatNumber value="${counterfoil.limitNum}"/>个
                                                </div>
                                            </div>
                                            <c:if test="${not empty counterfoil.remarks}">
                                                <div class="m-height">
                                                    <label class="activity-label">备注：</label>
                                                    <div class="activity-info activity-info-new">${counterfoil.remarks}</div>
                                                </div>
                                            </c:if>
                                        </div>
                                    </div>
                                </c:forEach>
                            </div>
                            <div id="eventDataDivNew" ${not empty activity.eventId && crowdfundEvent.isMultiple == 1 ? '' : 'style="display:none"'}>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label limit-num-label">人数上限：</label>
                                        <div class="layui-input-inline">
                                            <span class="limit-num"
                                                  style="height: 30px;line-height: 30px;padding-left: 10px;">${activity.limitNum}</span>人
                                            <input type="hidden" class="layui-input limit-num"
                                                   value="${activity.limitNum}" disabled lay-verify="limitNum">
                                        </div>
                                    </div>
                                </div>
                                <c:set var="numArray" value="${fn:split('一,二,三,四,五', ',')}"></c:set>
                                <c:forEach var="eventGradation" items="${eventGradations}" varStatus="status">
                                    <div class="layui-form-item multiple-activity-fb">
                                        <label class="activity-num">活动${numArray[status.index]}</label>
                                        <div class="activity-place">
                                            <div class="m-height">
                                                <label class="activity-label">活动地点：</label>
                                                <div class="activity-info">${eventGradation.cityName}${eventGradation.area}${eventGradation.place}</div>
                                            </div>
                                            <div class="m-height">
                                                <label class="activity-label">活动信息：</label>
                                                <div class="activity-info">
                                                    <fmt:formatNumber value="${eventGradation.price}" pattern="#.##"/>元/人
                                                </div>
                                                <label class="activity-label">截止时间：</label>
                                                <div class="activity-info">
                                                    <fmt:formatDate value="${eventGradation.endTime}"
                                                                    pattern="yyyy-MM-dd HH:mm"/>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </c:forEach>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">活动标题<span class="f-verify-red">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" maxlength="50" name="title" lay-verify="title" autocomplete="off"
                                       class="layui-input" value="${activity.title}"
                                       style="width: 50%; float: left; margin-right: 10px;">
                                <div class="layui-form-mid layui-word-aux">最多50字符</div>
                                <div class="cl"></div>
                                <input type="hidden" name="id" value="${activity.id}"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">发布者<span class="f-verify-red">*</span></label>
                                <div class="layui-input-inline" style="width: 300px">
                                    <c:if test="${empty activity.publisher}">
                                        <input type="text" name="publisher" lay-verify="publisher" autocomplete="off"
                                               class="layui-input" value="${sessionScope.newCurrentUser.realname}">
                                    </c:if>
                                    <c:if test="${not empty activity.publisher}">
                                        <input type="text" name="publisher" lay-verify="publisher" autocomplete="off"
                                               class="layui-input" value="${activity.publisher}">
                                    </c:if>
                                </div>
                                <div class="layui-form-mid layui-word-aux">默认显示当前机构名称，可以修改机构，最多30个字符</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">头像<span class="f-verify-red">*</span></label>
                            <div class="cover-content">
                                <c:if test="${activity == null || empty activity.publisherLogo}">
                                    <input type="hidden" name="publisherLogo" id="publisherLogo"
                                           lay-verify="publisherLogo"
                                           value="${sessionScope.newCurrentUser.logo}"/>
                                    <span id="logo-img" class="round-img"
                                          style="background-image:url(${sessionScope.newCurrentUser.logo})"></span>
                                </c:if>
                                <c:if test="${activity != null && not empty activity.publisherLogo}">
                                    <input type="hidden" name="publisherLogo" id="publisherLogo"
                                           lay-verify="publisherLogo"
                                           value="${activity.publisherLogo}"/>
                                    <span id="logo-img" class="round-img"
                                          style="background-image:url('${activity.publisherLogo}')"></span>
                                </c:if>
                                <a class="layui-btn layui-btn-danger" id="sel_logo_img">+添加头像</a>
                                <div class="form-word-aux">默认显示当前机构头像，可以修改头像</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">海报<span class="f-verify-red">*</span></label>
                            <div class="cover-content">
                                <input type="hidden" name="pic" id="pic" lay-verify="pic" value="${activity.pic}"/>
                                <c:if test="${activity == null || empty activity.pic}">
                                <span id="cover-img" class="cover-img"
                                      style="background-image:url(${ctx}/image/posterImg.png)"></span>
                                </c:if>
                                <c:if test="${activity != null && not empty activity.pic}">
                                <span id="cover-img" class="cover-img"
                                      style="background-image:url('${activity.pic}')"></span>
                                </c:if>
                                <a class="layui-btn layui-btn-danger" id="sel_pic_img">+添加海报</a>
                                <div class="form-word-aux">建议尺寸：800x450</div>
                            </div>
                        </div>
                        <div class="split-line"></div>
                        <div class="layui-form-item">
                            <div class="layui-inline" style="vertical-align: bottom;">
                                <label class="layui-form-label">隐藏数据<span class="f-verify-red">*</span></label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="templateStyle" value="0"
                                           title="否" ${activity == null || activity.templateStyle == 0 ? 'checked="checked"' : ''}>
                                    <input type="radio" name="templateStyle" value="1"
                                           title="是" ${activity != null && activity.templateStyle == 1 ? 'checked="checked"' : ''}>
                                </div>
                            </div>
                            <div class="dib calc-350">
                                <a class="red tip-link"
                                   href="javascript:openHiddenShow('手机效果展示图', '#hidden_show_plane')"><i
                                        class="iconfont icon-piclight"></i>效果展示图</a>
                                <p class="gray">说明:在前期众筹数据较少时，适当使用隐藏数据功能，可以避免推广的尴尬，等数据较多时可再调整</p>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">选择海报背景图<span class="f-verify-red">*</span></label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="isCustomPoster" lay-filter="isCustomPoster" value="0"
                                           title="默认" ${activity == null || activity.isCustomPoster == 0 ? 'checked="checked"' : ''}>
                                    <input type="radio" name="isCustomPoster" lay-filter="isCustomPoster" value="1"
                                           title="自定义" ${activity != null && activity.isCustomPoster == 1 ? 'checked="checked"' : ''}>
                                </div>
                                <div class="layui-inline"
                                     id="customPosterDiv" ${activity == null || activity.isCustomPoster == 0 ? 'style="display:none"' : ''}>
                                    <div class="u-single-upload">
                                        <c:if test="${activity != null && not empty activity.networkImagePath}">
                                            <a class="layui-btn layui-btn-danger" id="sel_poster_img">更换背景图</a>
                                        </c:if>
                                        <c:if test="${activity == null || empty activity.networkImagePath}">
                                            <a class="layui-btn layui-btn-danger" id="sel_poster_img">添加背景图</a>
                                        </c:if>
                                    </div>
                                    <div class="form-word-aux">建议像素：750x1334，建议大小：小于等于200KB</div>
                                </div>

                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <div class="layui-input-inline">
                                    <input type="hidden" name="networkImagePath" id="networkImagePath"
                                           lay-verify="networkImagePath" value="${activity.networkImagePath}"/>
                                    <c:if test="${activity == null || empty activity.networkImagePath}">
                                        <div id="zc-p-cover-img" class="img-item1"
                                             style="background-image: url(${ctx}/image/poster/19newYear_bz.png)">
                                        </div>
                                    </c:if>
                                    <c:if test="${activity != null && not empty activity.networkImagePath}">
                                        <div id="zc-p-cover-img" class="img-item1"
                                             style="background-image: url(${activity.networkImagePath})">
                                        </div>
                                    </c:if>
                                </div>
                            </div>
                        </div>
                        <c:if test="${not empty activity.id}">
                            <div class="layui-form-item">
                                <div class="layui-inline" style="vertical-align: bottom;">
                                    <label class="layui-form-label">分享编辑<span class="f-verify-red">*</span></label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="editShare" lay-filter="editShare" value="2"
                                               title="否" ${activity == null || empty activity.editShare || activity.editShare == 2 ? 'checked="checked"' : ''}>
                                        <input type="radio" name="editShare" lay-filter="editShare" value="1"
                                               title="是" ${activity != null && activity.editShare == 1 ? 'checked="checked"' : ''}>
                                    </div>
                                </div>
                                <div class="dib calc-350">
                                    <a class="red tip-link"
                                       href="javascript:openHiddenShow('第三方pc编辑页面效果图', '#hidden_show_plane2')"><i
                                            class="iconfont icon-piclight"></i>效果展示图</a>
                                    <p class="gray">说明:通过本功能，允许第三方直接通过PC端修改文章内容，便于合作伙伴调整，调整仅部分内容</p>
                                </div>
                            </div>
                            <div class="layui-form-item editShareDiv" ${activity == null || empty activity.editShare || activity.editShare == 2 ? 'style="display:none"' : ''}>
                                <div class="layui-inline" style="margin-left: 130px;">
                                    <div>
                                        <div class="dib">
                                            <span>访问编码</span>
                                            <input type="text" name="account" value="${thirdMember.account}"
                                                   class="layui-input"
                                                   style="display: inline-block; width: 120px" readonly/>
                                        </div>
                                        <div class="dib" style="width: 220px">
                                            <span>访问密码</span>
                                            <input type="text" name="password" value="${thirdMember.password}"
                                                   class="layui-input" style="display: inline-block; width: 150px"
                                                   readonly/>
                                        </div>
                                        <div class="mt10">
                                            <span>众筹编辑链接</span>
                                            <input type="text" name="url" value="${thirdMember.url}" class="layui-input"
                                                   style="display: inline-block; width: 400px" readonly/>
                                            <input type="hidden" name="uri" value="${thirdMember.uri}"/>
                                            <input type="hidden" name="alias" value="${thirdMember.alias}"/>
                                            <div class="dib">
                                                <button id="copySign" class="layui-btn layui-btn-danger" type="button">
                                                    复制链接、编码及密码
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </c:if>
                        <div class="layui-form-item">
                            <div class="layui-inline" style="vertical-align: bottom;">
                                <label class="layui-form-label">个人众筹页<span class="f-verify-red">*</span></label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="personalPopularPageState" value="0"
                                           title="显示所属主题报名人员" ${activity == null ||
                                            activity.personalPopularPageState == 0 ? 'checked="checked"' : ''}>
                                    <input type="radio" name="personalPopularPageState" value="1"
                                           title="显示该项目报名人员" ${activity == null ||
                                            activity.personalPopularPageState == 1 ? 'checked="checked"' : ''}>
                                    <input type="radio" name="personalPopularPageState" value="3"
                                           title="显示报名人员的支持者" ${activity == null ||
                                            activity.personalPopularPageState == 3 ? 'checked="checked"' : ''}>
                                    <input type="radio" name="personalPopularPageState" value="2"
                                           title="不显示" ${activity == null || activity.personalPopularPageState == 2 ?
                                            'checked="checked"' : ''}>
                                </div>
                                <div class="dib calc-350">
                                    <a class="red tip-link"
                                       href="javascript:openHiddenShow('手机效果展示图', '#hidden_show_plane3')"><i
                                            class="iconfont icon-piclight"></i>效果展示图</a>
                                    <p class="gray">说明：可以设置显示所属主题下的报名人员，或显示本项目下的报名人员，或显示报名人员的支持者</p>
                                </div>
                            </div>
                        </div>
                        <div class="split-line"></div>
                        <%--<%@include file="./cityAreaMapNew.jsp" %>--%>
                        <div class="layui-form-item">
                            <label class="layui-form-label">众筹宣言<span class="f-verify-red">*</span></label>
                            <div class="layui-input-block">
                            <textarea maxlength="100" class="layui-textarea calc-110" name="crowdDeclaration"
                                      lay-verify="crowd_xy"
                                      placeholder="请输入众筹宣言，让大家来参与报名吧！">${activity.crowdDeclaration}</textarea>
                                <div class="layui-form-mid layui-word-aux">最多100字符</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">支持宣言<span class="f-verify-red">*</span></label>
                            <div class="layui-input-block">
                            <textarea maxlength="100" class="layui-textarea calc-110" name="supportDeclaration"
                                      lay-verify="support_xy"
                                      placeholder="请输入支持宣言，让大家支持本次活动吧！">${activity.supportDeclaration}</textarea>
                                <div class="layui-form-mid layui-word-aux">最多100字符</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">联合发起宣言<span class="f-verify-red">*</span></label>
                            <div class="layui-input-block">
                            <textarea maxlength="100" class="layui-textarea calc-110" name="representDeclaration"
                                      lay-verify="represent_xy"
                                      placeholder="请输入联合发起宣言，让大家来参与联合发起吧！">${activity.representDeclaration}</textarea>
                                <div class="layui-form-mid layui-word-aux">最多100字符</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">活动描述</label>
                            <div class="layui-input-block">
                                <textarea maxlength="100" class="layui-textarea calc-110" name="remarks"
                                          placeholder="活动描述">${activity.remarks}</textarea>
                                <div class="layui-form-mid layui-word-aux">最多100字符</div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">轮播图</label>
                            <button class="layui-btn  layui-btn-danger" type="button" onclick="openUploadCI()">
                                +添加图片
                            </button>
                            <div class="layui-input-block" style="min-height: auto;">
                                <input type="hidden" name="picList" id="picList" lay-verify="picList"/>
                                <div class="zc-ci-img-list ci-img-list" id="img_list">
                                    <c:forEach var="resource" items="${picList}">
                                        <div class="item" data-url="${resource.resourceUrl}">
                                            <div class="img-item"
                                                 style="background-image: url('${resource.resourceUrl}')">
                                                <i class="layui-icon del-icon"
                                                   onclick="delQImg('${resource.resourceUrl}',this, '${resource.id}')">&#x1007;</i>
                                            </div>
                                                <%-- 									<input class="text-item" type="text" value="${resource.remarks}" placeholder="图片描述" /> --%>
                                        </div>
                                    </c:forEach>
                                </div>
                                <%--<a href="javascript:openUploadCI()" class="layui-btn  layui-btn-danger">+添加图片</a>--%>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">视频</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="videoList" id="videoList"/>
                                <div style="margin-bottom: 10px;">
                                <textarea class="layui-textarea video-link margin-right calc-110"
                                          readonly
                                          style="float: left; margin-right: 10px;resize:none;min-height: 80px"
                                          id="vide_code">${video.resourceUrl}</textarea>
                                    <a href="javascript:openUploadVideo()" class="red"
                                       style="display: inline-block; margin-bottom: 5px">添加视频</a>
                                    <a href="javascript:clearValue()" class="red" style="display: inline-block">清除视频</a>
                                    <div class="cl"></div>
                                </div>
                                <input type="text" maxlength="30" placeholder="请输入视频简介"
                                       class="layui-input video-remarks margin-right"
                                       style="width: calc(100% - 110px);"
                                       value="${video.remarks}">
                                <div class="layui-form-mid layui-word-aux">最多30字符</div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">活动详情<span class="f-verify-red">*</span></label>
                            <div class="layui-input-block" id="content11">
                                <div class="act-main-body activity-content" ${empty activity.eventId ? '' : 'style="display:none"'}>
                                    <div class="img-text-content"></div>
                                </div>
                                <div style="${empty activity.eventId ? 'display:none' : ''}">
                                    <script id="ueditor1" type="text/plain"></script>
                                </div>
                                <div style="display: none" id="contentView">${activityDetail.content}</div>
                                <input type="hidden" name="content" id="content" lay-verify="content"
                                       data-link-ue="ueditor1"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">报名相关</label>
                            <div class="layui-input-block" id="applyRelated">
                                <div class="act-main-body  apply-related">
                                    <div class="img-text-content">${activityDetail.applyRelated}</div>
                                    <a href="javascript:void(0);" onclick="toggleActCtn(this)"
                                       class="more-btn show-more-btn">展开所有<i class="iconfont icon-unfold"></i></a>
                                    <a href="javascript:void(0);" onclick="toggleActCtn(this)"
                                       class="more-btn hide-more-btn">收起<i class="iconfont icon-fold"></i></a>
                                </div>
                                <%--<script id="relatedUeditor" type="text/plain" style="width: 100%; height: 500px;"></script>--%>
                                <%--<div style="display: none" id="applyRelatedView">${activityDetail.applyRelated}</div>--%>
                                <%--<input type="hidden" name="applyRelated" id="applyRelated" lay-verify="applyRelated"  data-link-ue="relatedUeditor"/>--%>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">参赛标准</label>
                            <div class="layui-input-block" id="matchStandard">
                                <div class="act-main-body  match-standard">
                                    <div class="img-text-content">${activityDetail.matchStandard}</div>
                                    <a href="javascript:void(0);" onclick="toggleActCtn(this)"
                                       class="more-btn show-more-btn">展开所有<i class="iconfont icon-unfold"></i></a>
                                    <a href="javascript:void(0);" onclick="toggleActCtn(this)"
                                       class="more-btn hide-more-btn">收起<i class="iconfont icon-fold"></i></a>
                                </div>
                                <%--<script id="standardUeditor" type="text/plain" style="width: 100%; height: 500px;"></script>--%>
                                <%--<div style="display: none" id="matchStandardView">${activityDetail.matchStandard}</div>--%>
                                <%--<input type="hidden" name="matchStandard" id="matchStandard" lay-verify="matchStandard" data-link-ue="standardUeditor"/>--%>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <a href="javascript:void(0)" class="layui-btn layui-btn-danger" lay-submit
                                   lay-filter="*">立即提交</a>
                                <a href="${ctx}/activity/activity/zcActivityList.do"
                                   class="layui-btn layui-btn-primary">取消</a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!--底部-->
        <%@include file="../include/footer.jsp" %>
        <div style="display: none" id="create_date_str">
            <fmt:formatDate value="${activity.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
        </div>
        <c:set var="expirationTime" value="${memberForm:getExpirationTimeById(sessionScope.newCurrentUser.id)}"/>
        <c:set var="isExpire" value="${memberForm:isExpire(sessionScope.newCurrentUser.id, null)}"/>
    </section>
</div>


<script type="text/javascript" src="${ctxStatic}/UEditor/ueditor.config.js"></script>
<script type="text/javascript" src="${ctxStatic}/UEditor/ueditor.all.js"></script>
<script type="text/javascript" src="${ctxStatic}/UEditor/myplugin/uploadCI.js"></script>
<script type="text/javascript" src="${ctxStatic}/UEditor/myplugin/uploadVideo.js"></script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" src="${ctxStatic}/UEditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="${ctx}/script/common/form_cache.js"></script>
<script type="text/javascript" src="${ctx}/script/common/img_text.js"></script>
<script type="text/javascript" src="${ctx}/static/clipboard/clipboard.min.js"></script>
<script>
    var isCustomPoster_val = '${activity.isCustomPoster}';
    var networkImagePath_val = '${activity.networkImagePath}';
    var ue = UE.getEditor('ueditor1', {
        initialFrameWidth: 750,
        initialFrameHeight: 500
    });
    /*var relatedUeditor = UE.getEditor('relatedUeditor');
    var standardUeditor = UE.getEditor('standardUeditor');*/

    var form, formcache, maxNum = 5, isMultiple = '${crowdfundEvent.isMultiple}';
    if (isMultiple) {
        isMultiple = parseInt(isMultiple);
    }
    txz.initHeader({
        nav: [{
            name: '众筹项目',
            href: '${ctx}/activity/activity/zcActivityList.do',
        }, {
            name: '${empty activity.id ? '发布' : '编辑'}众筹项目',
            curr: true
        }],
        btns: [{
            type: 'back'
        }]
    });

    function verify(value, title) {
        if (value == "") {
            return "请填写" + title;
        }
    }

    function toggleActCtn(o) {
        $(o).parent().toggleClass('open');
    }

    $(function () {
        layui.use(['form', 'laydate'], function () {
            form = layui.form, laydate = layui.laydate;

            if (${empty activity.eventId}) {
                $("form").find(":input").prop("disabled", true);
                $("#eventId").prop("disabled", false);
                $("form").find(".u-single-upload").css("opacity", ".4");
                $("form").find(".u-single-upload .u-single-upload-icon").css("opacity", "1");

                /*layer.msg("请先选择主题");*/
            }

            form.on('select(eventId)', function (data) {
                //loading层
                var loadIndex = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });
                if (data.value == "") {
                    $("form").find("input[type=text]").val("");
                    $("form").find("textarea").text("");
                    $("[name=crowdfundHintSwitch][value='0']").prop("checked", true);
                    $("#eventDataDiv").css("display", "none");
                    $("#cover-img").css("background-image", "url('${ctx}/image/posterImg.png')");
                    $("#logo-img").css("background-image", "url('${ctx}/image/def_user_logo.png')");
                    $("#img_list").html("");
                    $(".act-main-body .img-text-content").html("");

                    $(".activity-content").css("display", "block");
                    $("#ueditor1").parent().css("display", "none");

                    $("form").find(":input").prop("disabled", true);
                    $("#eventId").prop("disabled", false);
                    $("form").find(".u-single-upload").css("opacity", ".4");
                    $("form").find(".u-single-upload .u-single-upload-icon").css("opacity", "1");
                    form.render('select');
                    layer.close(loadIndex);
                } else {
                    $.post("${ctx}/crowdfund/event/getData.do", {eventId: data.value}, function (res) {
                        if (res.success) {
                            var activity = res.data.activity;
                            isMultiple = res.data.isMultiple;
                            if (res.data.isMultiple == 0) {
                                $(".end-time").val(res.data.endDate);
                                $(".start-time").val(res.data.startDate);
                                // $(".price").val(activity.price);
                                // $(".price").text(activity.price);

                                var _numArray = ['一', '二', '三'];
                                var _array = new Array();
                                $.each(res.data.counterfoils, function (index, counterfoil) {
                                    _array.push('<div class="layui-form-item multiple-activity-fb count-activity-fb">' +
                                        '                                        <label class="activity-num">套餐' + _numArray[counterfoil.sort - 1] + '</label>' +
                                        '                                        <div class="activity-place">' +
                                        '                                            <div class="m-height">' +
                                        '                                                <label class="activity-label">名称：</label>' +
                                        '                                                <div class="activity-info">' + counterfoil.name + '</div>' +
                                        '                                            </div>' +
                                        '                                            <div class="m-height">' +
                                        '                                                <label class="activity-label">金额：</label>' +
                                        '                                                <div class="activity-info">' + counterfoil.payment + '元</div>' +
                                        '                                                <label class="activity-label">限制数量：</label>' +
                                        '                                                <div class="activity-info">' + counterfoil.limitNum + '个</div>' +
                                        '                                            </div>' +
                                        '                                            <div class="m-height">' +
                                        '                                                <label class="activity-label">备注：</label>' +
                                        '                                                <div class="activity-info activity-info-new">' + counterfoil.remarks + '</div>' +
                                        '                                            </div>' +
                                        '                                        </div>' +
                                        '                                    </div>');
                                });
                                $("#eventDataDiv").append(_array.join(''));

                                $(".address").val(res.data.address);
                                $(".limit-num").val(activity.limitNum);
                                $(".limit-num").text(activity.limitNum);
                                $("#eventDataDiv").css("display", "block");
                                $("#eventDataDivNew").hide();
                                $("form").attr('action', '${ctx}/activity/zcActivity/save.do');
                            } else {
                                var _numArray = ['一', '二', '三', '四', '五'];
                                var _array = new Array('<div class="layui-form-item">\n' +
                                    '                                    <div class="layui-inline">\n' +
                                    '                                        <label class="layui-form-label limit-num-label">人数上限：</label>\n' +
                                    '                                        <div class="layui-input-inline">\n' +
                                    '                                            <span class="limit-num" style="height: 30px;line-height: 30px;padding-left: 10px;">' + activity.limitNum + '</span>人\n' +
                                    '                                            <input type="hidden" class="layui-input limit-num" value="' + activity.limitNum + '" disabled lay-verify="limitNum">\n' +
                                    '                                        </div>\n' +
                                    '                                    </div>\n' +
                                    '                                </div>');
                                $.each(res.data.eventGradations, function (index, gradation) {
                                    _array.push('<div class="layui-form-item multiple-activity-fb">' +
                                        '                                        <label class="activity-num">活动' + _numArray[gradation.gradation - 1] + '</label>' +
                                        '                                        <div class="activity-place">' +
                                        '                                            <div class="m-height">' +
                                        '                                                <label class="activity-label">活动地点：</label>' +
                                        '                                                <div class="activity-info">' + gradation.cityName + gradation.area + gradation.place + '</div>' +
                                        '                                            </div>' +
                                        '                                            <div class="m-height">' +
                                        '                                                <label class="activity-label">活动信息：</label>' +
                                        '                                                <div class="activity-info">' + gradation.price + '元/人</div>' +
                                        '                                                <label class="activity-label">截止时间：</label>' +
                                        '                                                <div class="activity-info">' + util.getDateStr(gradation.endTime).Format('yyyy-MM-dd HH:mm') + '</div>' +
                                        '                                            </div>' +
                                        '                                        </div>' +
                                        '                                    </div>');
                                })
                                $("#eventDataDivNew").html(_array.join(''));
                                $("#eventDataDivNew").css("display", "block");
                                $("#eventDataDiv").hide();
                                $("form").attr('action', '${ctx}/activityMultiple/zcActivity/save.do');
                            }

                            $("[name=title]").val(activity.title);
                            $("#cover-img").css("background-image", "url(" + activity.pic + ")");
                            $("[name=pic]").val(activity.pic);
                            $("[name=crowdDeclaration]").text(activity.crowdDeclaration);
                            $("[name=supportDeclaration]").text(activity.supportDeclaration);
                            $("[name=representDeclaration]").text(activity.representDeclaration);


                            $("[name=isCustomPoster][value='" + activity.isCustomPoster + "']").prop("checked", true);
                            var icu = activity.isCustomPoster;

                            if (0 == icu) {
                                $("#zc-p-cover-img").css("background-image", "url(" + "${ctx}/image/poster/19newYear_bz.png" + ")");
                            } else {
                                $("#zc-p-cover-img").css("background-image", "url(" + activity.networkImagePath + ")");
                                $("[name=networkImagePath]").val(activity.networkImagePath);
                            }


                            $("[name=remarks]").text(activity.remarks);
                            $("[name=eventId]").val(activity.eventId);
                            $("[name=crowdfundHintSwitch][value='" + activity.crowdfundHintSwitch + "']").prop("checked", true);
                            $("[name=personalPopularPageState][value='" + activity.personalPopularPageState + "']").prop("checked", true);
                            var picList = res.data.picList;
                            $("#img_list").html("");
                            for (var i = 0; i < picList.length; i++) {
                                $("#img_list").append('<div class="item" data-url="' + picList[i].resourceUrl + '">' +
                                    '<div class="img-item" style="background-image: url(' + picList[i].resourceUrl + ')">' +
                                    '<i class="layui-icon del-icon" onclick="delQImg(\'' + picList[i].resourceUrl + '\',this, \'\')">&#x1007;</i>' +
                                    '</div>' +
                                    '</div>');
                            }

                            var video = res.data.video;
                            if (video != null) {
                                $(".video-link").text(video.resourceUrl);
                                $(".video-remarks").text(video.remarks);
                            }

                            var detail = res.data.activityDetail;
                            if (detail != null) {
                                $(".activity-content").css("display", "none");
                                $("#ueditor1").parent().css("display", "block");
                                $("#contentView").html(detail.content);
                                ue.setContent($("#contentView").html());
                                if ($("#contentView").html() != "" && $("#contentView").html().length > 500) {
                                    ue.setHeight(850);
                                } else {
                                    ue.setHeight(500);
                                }
                                $(".apply-related div").html(detail.applyRelated);
                                $(".match-standard div").html(detail.matchStandard);
                            }

                            $("form").find(":input").prop("disabled", false);
                            $("#eventDataDiv").find(":input").prop("disabled", true);
                            $("form").find(".u-single-upload").css("opacity", "1");
                            $("form").find(".u-single-upload .u-single-upload-icon").css("opacity", "1");
                            form.render('radio');
                            form.render('select');
                        }
                        layer.close(loadIndex);
                    })
                }
            })

            $(".img-text-content").each(function (index, element) {
                imgText.initImgNew(this);
            });

            var detailSettings = {
                parent: $('#applyRelated .img-text-content')
            };
            $('.lazy-img').picLazyLoad(detailSettings);

            var noticeSettings = {
                parent: $('#matchStandard .img-text-content')
            };
            $('.lazy-img').picLazyLoad(noticeSettings);

            //自定义验证规则
            form.verify({
                eventId: function (value) {
                    if (value == "") {
                        return "请选择众筹主题";
                    }
                },
                groupIsExpire: function () {
                    if ('${isExpire}' == 'true' && '${activity.id}' == '') {
                        txz.openExpireDialog();
                        return false;
                    }
                    return "";
                },
                title: function (value) {
                    return verify(value, "活动标题");
                },
                crowd_xy: function (value) {
                    return verify(value, "众筹宣言");
                },
                support_xy: function (value) {
                    return verify(value, "支持宣言");
                },
                represent_xy: function (value) {
                    return verify(value, "联合发起宣言");
                },
                publisher: function (value) {
                    if (value == "") {
                        return "请填写发布者";
                    }
                },
                publisherLogo: function (value) {
                    if (value == "") {
                        return "请上传发布者头像";
                    }
                },
                pic: function (value) {
                    if (value == "") {
                        return "请上传活动海报";
                    }
                },
                endDate: function (value) {
                    if (isMultiple == 0) {
                        if (value == "") {
                            return "请去主题上选择报名截止时间";
                        }
                        if ('${isExpire}' !== 'true') {
                            if (util.getTimeMillis(value) < util.getTimeMillis()) {
                                return "截止时间不得早于当前时间";
                            }

                            var max = '${memberForm:dateFormat(expirationTime, 'yyyy-MM-dd HH:mm:ss')}';
                            if (value >= max) {
                                return "截止时间不能超过账户过期时间，请去主题上更改";
                            }
                        }
                    }
                },
                startDate: function (value) {
                    if (isMultiple == 0) {
                        if (value == "") {
                            return "请去主题上选择活动开始时间";
                        }

                        var endDate = $("[name=endDate]").val();
                        if (endDate >= value) {
                            return "活动开始时间不能早于报名截止时间";
                        }

                        if ('${isExpire}' !== 'true') {
                            if (util.getTimeMillis(value) < util.getTimeMillis()) {
                                return "活动开始时间不得早于当前时间";
                            }
                        }
                    }
                },
                address: function (value) {
                    if (isMultiple == 0) {
                        if (value == "") {
                            return "请去主题上选择活动地点";
                        }
                    }
                },
                /*limitNum: function (value) {
                    if (isMultiple == 0) {
                        if (value == "") {
                            return "请去主题上输入活动人数上限";
                        } else if (!util.checkNumber(value)) {
                            return "请输入正确的数字";
                        } else if (parseInt(value) == 0) {
                            return "请输入大于0的数字";
                        }
                    }
                },
                price: function (value) {
                    if (isMultiple == 0) {
                        if (value == "") {
                            return "请去主题上输入活动报名金额";
                        } else if (!util.checkFloat(value)) {
                            return "请输入正确的金额";
                        } else if (parseFloat(value) == 0) {
                            return "请输入大于0的金额";
                        }
                    }
                },*/
                content: function (value) {
                    $("#contentView").html(ue.getContent());
                    var content = $("#contentView").html();
                    if (content == "") {
                        return "请填写活动详情";
                    }
                },
                picList: function () {
                    // 跑马灯
                    var length = $("#img_list .img-item").length;
                    if (length > 5) {
                        return "最多只允许上传5张图片";
                    }
                }
            });

            form.on('radio(editShare)', function (data) {
                var editShare = $("[name=editShare]:checked").val();
                if (editShare == 1) {
                    $.post("${ctx}/activity/zcActivity/generateInfo.do", {id: '${activity.id}'}, function (res) {
                        if (res.success) {
                            $("[name=url]").val(location.origin + '/web' + res.data.url);
                            $("[name=uri]").val('/web' + res.data.url);
                            $("[name=alias]").val(res.data.alias);
                            $("[name=account]").val(res.data.account);
                            $("[name=password]").val(res.data.password);


                            $(".editShareDiv").show();
                        }
                    })
                } else {
                    $(".editShareDiv").hide();
                }
            })
            //海报背景
            form.on('radio(isCustomPoster)', function (data) {
                isCustomPoster_val = data.value;
                if (isCustomPoster_val == 0) {
                    $('#zc-p-cover-img').css('background-image', 'url(' + "${ctx}/image/poster/19newYear_bz.png" + ')');
                    networkImagePath_val = $('#networkImagePath').val();
                    $('#networkImagePath').val("");
                    $("#customPosterDiv").hide();
                } else {
                    if (networkImagePath_val == '') {
                        networkImagePath_val = "${ctx}/image/posterImg.png";
                    }
                    if ($('#networkImagePath').val() == '') {
                        $('#networkImagePath').val(networkImagePath_val);
                    }

                    $('#zc-p-cover-img').css('background-image', 'url(' + networkImagePath_val + ')');
                    $("#customPosterDiv").show();
                }
                form.render();
            });

            //监听提交
            form.on('submit', function (data) {
                formSubmit(data);
            });
            form.render('radio');
            form.render('select');
            $('.tx-form-qicon').each(function (i, item) {
                txz.openQTip(item);
            })

            var min;
            if (${empty activity.id}) {
                min = new Date().Format('yyyy-MM-dd HH:mm:ss');
            } else {
                min = $("#create_date_str").text();
            }

            //日期
            var start = {
                elem: '#startTime',
                min: min,
                max: '2099-06-16 23:59',
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm'
            };

            var end = {
                elem: '#endTime',
                min: min,
                max: '2099-06-16 23:59',
                type: 'datetime',
                format: 'yyyy-MM-dd HH:mm' //日期格式
            };
            laydate.render(start);
            laydate.render(end);

            //初始化地图控件
            <%--txz.Map.init({--%>
            <%--layForm: form,--%>
            <%--data: {--%>
            <%--cityId: '${activity.cityId}',--%>
            <%--areaInput: '${activity.area}',--%>
            <%--place: '${activity.place}',--%>
            <%--cityName: '${cityName}',--%>
            <%--lat: '${activity.lat}',--%>
            <%--lng: '${activity.lng}'--%>
            <%--}--%>
            <%--});--%>
        });
        txz.saveStatus = false;
        ue.addListener('ready', function () {
            this.setHeight(500);
            if ($("#contentView").html() != "") {
                this.setHeight(850);
            }
            this.setContent($("#contentView").html());
            //等待ueditor加载完后加载缓存
            if (!'${activity.id}') { //新增时使用
                formcache = new fCache({
                    fCacheKey: 'form_cache_zcact',//暂存的key
                    cacheCallback: loadCacheData,//获取到缓存后加载的方法
                    getFormData: getFormData
                }).init();
            }
        });
        ue.addListener('blur', function () {
            $("#contentView").html(ue.getContent());
        });


        $('#sel_pic_img').click(function () {
            txz.openSelImg({
                min: 1,
                max: 1,
                info: '建议尺寸：800x450',
                type: '<%=TargetType.ZC_ACTIVITY.getCode()%>',
                cb: function (imgs) {
                    $('#cover-img').css('background-image', 'url(' + imgs[0].path + ')');
                    $('#pic').val(imgs[0].path);
                }
            })
        })
        $('#sel_logo_img').click(function () {
            txz.openSelImg({
                min: 1,
                max: 1,
                info: '建议尺寸：120x120',
                type: '<%=TargetType.LOGO.getCode()%>',
                cb: function (imgs) {
                    $('#logo-img').css('background-image', 'url(' + imgs[0].path + ')');
                    $('#publisherLogo').val(imgs[0].path);
                }
            })
        })

        $('#copySign').on('click', function () {
            var cpval = "";
            cpval += "链接：" + $("[name=url]").val();
            cpval += "  访问编码：" + $("[name=account]").val();
            cpval += "  密码：" + $("[name=password]").val();

            $('#copySign').attr('data-clipboard-text', cpval);
            var clipboard = new ClipboardJS('#copySign');
            clipboard.on('success', function (e) {
                util.layerMsgSuccess("复制成功")
            });
            clipboard.on('error', function (e) {
                util.layerMsgError('复制失败');
            });
        })

        $('#sel_poster_img').click(function () {
            txz.openSelImg({
                min: 1,
                max: 1,
                info: '建议尺寸：750x1334',
                type: '<%=TargetType.ZC_P_POSTER.getCode()%>',
                cb: function (imgs) {
                    $('#zc-p-cover-img').css('background-image', 'url(' + imgs[0].path + ')');
                    $('#networkImagePath').val(imgs[0].path);
                }
            })
        })

    })

    //此方法用于加载缓存数据
    function loadCacheData(cacheData) {
        //跑马灯
        if (cacheData['picList']) {
            var picList = JSON.parse(cacheData['picList']);
            if (picList && picList.length > 0) {
                $("#img_list").html('');
                for (var i = 0, item; i < picList.length; i++) {
                    item = picList[i];
                    $("#img_list").append('<div class="item" data-url="' + item.pic + '">' +
                        '<div class="img-item" style="background-image: url(' + item.pic + ')">' +
                        '<i class="layui-icon del-icon" onclick="delQImg(\'' + item.pic + '\',this, \'\')">&#x1007;</i>' +
                        '</div>' +
                        //'<input class="text-item" type="text" placeholder="图片描述" />'+
                        '</div>');
                }
            }
        }
        //加载视频数据
        if (cacheData['videoList']) {
            var video = JSON.parse(cacheData['videoList']);
            $('.video-link').val(video.pic);
            $('.video-remarks').val(video.remarks);
        }
        //加载头像
        if (cacheData['publisherLogo']) {
            $('#logo-img').css('background-image', 'url(' + cacheData['publisherLogo'] + ')');
        }
        //加载封面图
        if (cacheData['pic']) {
            $('#cover-img').css('background-image', 'url(' + cacheData['pic'] + ')');
        }
        if (cacheData['publicQrCode']) {
            $('#publicQrCode_img').css('background-image', 'url(' + cacheData['publicQrCode'] + ')');
        }
        if (cacheData['serviceQrCode']) {
            $('#serviceQrCode_img').css('background-image', 'url(' + cacheData['serviceQrCode'] + ')');
        }
        form.render();
        /*txz.Map.init({
            layForm: form,
            data: {
                cityId: cacheData.cityId,
                areaInput: cacheData.areaSelect || cacheData.areaInput,
                place: cacheData.place,
                lat: cacheData.lat,
                lng: cacheData.lng
            }
        });*/
    }

    function getFormData() {
        $("#content").val(ue.getContent().replace(/&quot;/gi, ""));
//        $("#applyRelated").val(relatedUeditor.getContent().replace(/&quot;/gi, ""));
//        $("#matchStandard").val(standardUeditor.getContent().replace(/&quot;/gi, ""));
        // 跑马灯
        var array = new Array();
        $("#img_list .item").each(function (index, element) {
            var pic = {
                pic: $(element).attr("data-url"),
                remarks: $(element).find(".text-item").val() || ''
            }
            array.push(pic);
        });
        $("#picList").val(JSON.stringify(array));
        // 视频
        var video = {
            pic: $(".video-link").val(),
            remarks: $(".video-remarks").val()
        }
        $("#videoList").val(JSON.stringify(video));

        return util.serializeForm($('#myForm').serializeArray());
    }

    //表单提交
    function formSubmit(data) {
        var formData = getFormData();
        txz.submitObject(data.elem, function (callBack) {
            var action = $("#myForm").attr("action");
            txz.ajaxRequest({
                method: 'post',
                url: action,
                saveCache: true,
                cacheObj: formcache,
                params: formData,
                callBack: function (res) {
                    typeof callBack === 'function' && callBack();
                    if (res.success) {
                        if ($(data.elem).hasClass('preview-btn')) {
                            if ('${empty activity.id}' === 'true') {
                                location.href = '${ctx}/activity/activity/publishZcAct.do?id=' + res.data;
                            } else {
                                var $previewFrame = $($('.preview-box').find('iframe')[0].contentWindow.document).find('iframe');
                                $previewFrame.attr('src', $previewFrame.attr('src'));
                            }
                        } else {
                            util.layerMsgSuccess("提交成功", function () {
                                location.href = "${ctx}/activity/activity/zcActivityList.do";
                            });
                        }
                    } else {
                        util.layerMsgError("提交失败")
                    }
                }
            });
        })
        return false;
    }

    // 文本编辑器图片上传
    function uEditorUploadCI(editor) {
        txz.openSelImg({
            min: 1,
            type: '<%=TargetType.ZC_ACTIVITY.getCode()%>',
            cb: function (imgs) {
                if (imgs.length) {
                    for (var i = 0, item; i < imgs.length; i++) {
                        item = imgs[i];
                        editor.focus();
                        editor.execCommand('inserthtml', item.htmlStr);
                    }
                }
            }
        })
    }

    function uEditorUploadCIVideo(editor) {
        txz.openSelVideo({
            min: 1,
            type: '<%=TargetType.ZC_ACTIVITY.getCode()%>',
            cb: function (imgs) {
                if (imgs.length) {
                    for (var i = 0, item; i < imgs.length; i++) {
                        item = imgs[i];
                        editor.focus();
                        editor.execCommand('inserthtml', item.htmlStr);
                    }
                }
            }
        })
    }

    function openUploadCI() {
        var picLength = $(".ci-img-list .item").length;
        var maxLength = maxNum - picLength <= 0 ? 0 : maxNum - picLength;
        txz.openSelImg({
            min: 1,
            max: maxLength,
            type: '<%=TargetType.ZC_ACTIVITY.getCode()%>',
            cb: function (imgs) {
                if (imgs.length) {
                    for (var i = 0, item; i < imgs.length; i++) {
                        item = imgs[i];
                        $("#img_list").append('<div class="item" data-url="' + item.path + '">' +
                            '<div class="img-item" style="background-image: url(' + item.path + ')">' +
                            '<i class="layui-icon del-icon" onclick="delQImg(\'' + item.path + '\',this, \'\')">&#x1007;</i>' +
                            '</div>' +
                            //'<input class="text-item" type="text" placeholder="图片描述" />'+
                            '</div>');
                    }
                }
            }
        })
    }

    function delQImg(picUrl, obj, resourceId) {
        $(obj).closest(".item").remove();
    }

    function openUploadVideo() {
        txz.openSelVideo({
            min: 1,
            max: 1,
            backVideoOrIframe: 'video',
            type: '<%=TargetType.ZC_ACTIVITY.getCode()%>',
            cb: function (imgs) {
                if (imgs.length) {
                    for (var i = 0, item; i < imgs.length; i++) {
                        item = imgs[i];
                        $("#vide_code").val(item.htmlStr);
                    }
                }
            }
        })
    }

    function clearValue() {
        $("#vide_code").val("");
    }

    function openHiddenShow(title, container) {
        var index = layer.open({
            type: 1,
            area: ['800px', '700px'],
            title: [title, 'text-align:center;'],
            shade: 0.6,
            shadeClose: true,
            content: $(container)
        });
    }
</script>
</body>
</html>